<template>
<h1>员工列表练习</h1>
  <input type="text" name="name" placeholder="请输入员工姓名" v-model="Employee.name">
  <input type="text" name="salary"  placeholder="请输入员工工资" v-model="Employee.salary">
  <input type="text" name="position" placeholder="请输入员工岗位" v-model="Employee.position">
  <button @click="addEmployee">添加员工</button>
  <br>
  <table border="1" style="margin: 0 auto">
    <tr>
      <th>序号</th>
      <th>姓名</th>
      <th>工资</th>
      <th>岗位</th>
    </tr>
    <tr v-for="(item,index) in EmployeeList" >
      <td>{{index+1}}</td>
      <td>{{item.name}}</td>
      <td>{{item.salary}}</td>
      <td>{{item.position}}</td>
    </tr>
  </table>
</template>

<script setup>
import {ref} from "vue";

let Employee=ref(
    {
        name:"",
        salary:"",
        position:""
    }
)
let EmployeeList=ref([]);
let addEmployee=()=>{
    console.log(Employee.value);
    console.log(EmployeeList.value)
    EmployeeList.value.push(Employee.value);
    Employee.value={
        name:"",
        salary:"",
        position:""
    }
}
</script>

<style scoped>

</style>